/**
 * Created by JetBrains PhpStorm.
 * User: Minh Thuan
 * Date: 4/15/12
 * Time: 3:40 PM
 * To change this template use File | Settings | File Templates.
 */
// JavaScript Document
/**
 +---------------------------------------+
 | @author <phuonglh@peacesoft.net>		|
 | @version NL 2.0						|
 | @created 01/2010						|
 | 										|
 +---------------------------------------+
 */
function leftTrim(value)
{
    index = 0;
    while(value.indexOf(' ', index) == index) {
        index++;
    }
    return value.substring(index, value.length);
}
function rightTrim(value)
{
    index = value.length-1;
    while(value.indexOf(' ',index) == index) {
        index--;
    }
    return value.substring(0, index+1);
}
function trim(value)
{
    value = leftTrim(value);
    value = rightTrim(value);
    return value;
}
//
function isSelect(value, def)
{
    return (value != def);
}
//
function notEmpty(value)
{
    return checkLength(value, 1);
}
// hÃ m kiá»ƒm tra Ä‘á»™ dÃ i chuá»—i
function checkLength(value, min, max)
{
    value = trim(value);
    if (value.length < min) {
        return false;
    }
    if (max !== null && value.length > max) {
        return false;
    }
    return true;
}
// hÃ m kiá»ƒm tra tÃªn ngÆ°á»i dÃ¹ng
function isUserName(value)
{
    var re = new RegExp(/^[a-zA-Z0-9_\-]{6,25}$/);
    if(value.search(re)==-1)
    {
        return false;
    }
    return true;
}
// hÃ m kiá»ƒm tra ngÃ y thÃ¡ng
function isDate(value)
{
    var re = new RegExp(/^\d{1,2}[\/-]\d{1,2}[\/-]\d{4}$/);
    if(value.search(re)==-1)
    {
        return false;
    }
    return true;
}
// hÃ m kiá»ƒm tra email
function isEmail(value)
{
    //var re = new RegExp(/^([a-zA-Z][a-zA-Z0-9_\-]*(([a-zA-Z0-9][\.][a-zA-Z0-9][a-zA-Z0-9_\-]*)*)[a-zA-Z0-9]@([a-zA-Z][a-zA-Z0-9_\-]*[a-zA-Z0-9]\.)+([a-zA-Z0-9]{2,4}))$/);
    var re = new RegExp(/^([a-zA-Z0-9][a-zA-Z0-9_\-]*(([\.][a-zA-Z0-9_\-]*)*)[a-zA-Z0-9]@([a-zA-Z0-9][a-zA-Z0-9_\-]*[a-zA-Z0-9]\.)+([a-zA-Z0-9]{2,4}))$/);
    if(value.search(re)==-1)
    {
        return false;
    }
    return true;
}
// hÃ m kiá»ƒm tra tÃ i khoáº£n ngÃ¢n hÃ ng
function isBank(value)
{
    var re = new RegExp(/^\d{5,18}$/);
    if(value.search(re)==-1)
    {
        return false;
    }
    return true;
}
// hÃ m kiá»ƒm tra sá»‘
function isNumeric(value)
{
    var re = new RegExp(/^\d+$/);
    if(value.search(re)==-1)
    {
        return false;
    }
    return true;
}
// hÃ m kiá»ƒm tra sá»‘ tiá»n
function isAmount(value)
{
    var re = new RegExp(/^[0-9\.]{1,}$/);
    if(value.search(re)==-1)
    {
        return false;
    }
    return true;
}
// hÃ m kiá»ƒm tra sá»‘ mobile
function isMobile(value)
{
    var re = new RegExp(/^\d{10,11}$/);
    if(value.search(re)==-1)
    {
        return false;
    }
    return true;
}
// hÃ m kiá»ƒm tra sá»‘ Ä‘iá»‡n thoáº¡i
function isPhoneNumber(value)
{
    var re = new RegExp(/^\d{7,15}$/);
    if(value.search(re)==-1)
    {
        return false;
    }
    return true;
}
// hÃ m kiá»ƒm tra sá»‘ chá»©ng thá»±c
function isVerifyNumber(value)
{
    var re = new RegExp(/^[a-zA-Z0-9\/_-]{6,20}$/);
    if(value.search(re)==-1)
    {
        return false;
    }
    return true;
}
// hÃ m kiá»ƒm tra máº­t kháº©u
function isPassword(value)
{
    var re = new RegExp(/^[\S]{6,30}$/);
    if(value.search(re)==-1)
    {
        return false;
    }
    return true;
}
//HÃ m hiá»‡n áº£nh
function Tip()
{
    tt_Tip(arguments, null);
}
function TagToTip()
{
    var t2t = tt_GetElt(arguments[0]);
    if(t2t)
        tt_Tip(arguments, t2t);
}
function UnTip()
{
    tt_OpReHref();
    if(tt_aV[DURATION] < 0 && (tt_iState & 0x2))
        tt_tDurt.Timer("tt_HideInit()", -tt_aV[DURATION], true);
    else if(!(tt_aV[STICKY] && (tt_iState & 0x2)))
        tt_HideInit();
}